package cn.yanghan.doc;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * 创建ES的文档对象
 * 该文档对象用来如下几个事情
 * 索引库的创建
 * 文档的映射
 * 存储到ES的数据封装
 */
@Document(indexName = "course" , type = "_doc")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CourseDoc {

    //对应ES的文档id
    @Id
    private Long id;

    //使用text要分词，使用keyword不分词
    //加上ik代表支持中文分词
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String name;//课程名字

    //课程等级
    @Field(type = FieldType.Keyword)
    private String gradeName;

    //课程的分类
    @Field(type = FieldType.Long)
    private Long courseTypeId;

    //机构名字
    @Field(type = FieldType.Keyword)
    private String tenantName;

    //课程封面
    @Field(type = FieldType.Keyword)
    private String pic;

    //课程销量
    @Field(type = FieldType.Integer)
    private Integer saleCount;

    //课程浏览量
    @Field(type = FieldType.Integer)
    private Integer viewCount;

    //课程评论
    @Field(type = FieldType.Integer)
    private Integer commentCount;

    //课程收费规则
    @Field(type = FieldType.Keyword)
    private String chargeName;

    //现价
    @Field(type = FieldType.Float)
    private Float price;

    //原价
    @Field(type = FieldType.Float)
    private Float priceOld;

    //上架时间
    @Field(type = FieldType.Date)
    private Date onLineTime;
}
